<?php if(!class_exists('raintpl')){exit;}?><?php if( $user['level_name']=='officer' ){ ?>
<div style = "border:2px solid #ccc; padding:10px;margin-bottom:20px;">
<form action = "formula-update.php" method = "post">
	<input type = "hidden" name = "id" value = "<?php echo $assessment['id'];?>">
	<h2>สูตรคำนวน</h2>
	<br>
	1). <input type = "text" name = "formula_text" class = "w500" value = "<?php echo $assessment['formula_text'];?>"><br><br>
	2). แปลงค่าร้อยละที่คำนวนได้ในข้อที่ 1). เทียบกับคะแนนเต็ม 5<br><br>
	<hr><br>
	กำหนดให้เป็นคะแนนเต็ม 5 เท่ากับ
	<input type = "text" name = "percent" class = "w50" value ="<?php echo $assessment['percent'];?>">
	<select name = "unit">
		<option value = "1" <?php echo $check["0"];?>>หน่วย</option>
		<option value = "2" <?php echo $check["1"];?>>เปอร์เซ็น</option>
	</select>
	<br><br>
	<input type = "submit" value = "ตกลง">
</form>
</div>
<?php }else{ ?>
<div style = "border:2px solid #ccc; padding:10px;margin-bottom:20px;">
<form action = "formula-cal.php" method = "post">
	<input type = "hidden" name = "id" value = "<?php echo $assessment['id'];?>">
	<h2>สูตรคำนวน</h2>
	<br>
	1). <?php echo $assessment['formula_text'];?><br><br>
	<div class = "w300">
		<div class = "selectbox">
			<input type = "hidden" name = "common1" value = "<?php echo $common1['id'];?>">
			<?php if( $assessment['common1']==0 ){ ?>
				<span>เลือก common data set<img src="http://localhost/kpi/html/./images/arrow_down.png" class = "fr"></span>
			<?php }else{ ?>
				<span><?php echo $common1['name'];?> (<?php echo $common1['target'];?>)<img src="http://localhost/kpi/html/./images/arrow_down.png" class = "fr"></span>
			<?php } ?>
			<ul>
				<?php $counter1=-1; if( isset($common) && is_array($common) && sizeof($common) ) foreach( $common as $key1 => $value1 ){ $counter1++; ?>
				<li val = "<?php echo $value1["id"];?>"><?php echo $value1["name"];?> (<?php echo $value1["target"];?>)</li>
				<?php } ?>
			</ul>
			<div class = "clear"></div>
		</div>
		<div style = "float:right;font-size:16px;position:relative;left:200px;top:-5px;"><?php if( $assessment['unit']==2 ){ ?>x 100<?php } ?> = <input type = "text" name = "result1" class = "w80" value = "<?php echo $assessment['result'];?>" readonly="readonly"></div>
		<hr>
		<div class = "selectbox">
			<input type = "hidden" name = "common2" value = "<?php echo $common2['id'];?>">
			<?php if( $assessment['common2']==0 ){ ?>
				<span>เลือก common data set<img src="http://localhost/kpi/html/./images/arrow_down.png" class = "fr"></span>
			<?php }else{ ?>
				<span><?php echo $common2['name'];?> (<?php echo $common2['target'];?>)<img src="http://localhost/kpi/html/./images/arrow_down.png" class = "fr"></span>
			<?php } ?>
			<ul>
				<?php $counter1=-1; if( isset($common) && is_array($common) && sizeof($common) ) foreach( $common as $key1 => $value1 ){ $counter1++; ?>
				<li val = "<?php echo $value1["id"];?>"><?php echo $value1["name"];?> (<?php echo $value1["target"];?>)</li>
				<?php } ?>
			</ul>
			<div class = "clear"></div>
		</div>
	</div>
	<br><br>

	2). แปลงค่าร้อยละที่คำนวนได้ในข้อที่ 1). เทียบกับคะแนนเต็ม 5<br><br>
	<div class = "w200">
		<input type = "text" name = "result2" class = "w80" value = "<?php echo $assessment['result'];?>">
		<div style = "float:right;font-size:16px;position:relative;left:80px;top:-5px;z-index:1">x 5 = <input type = "text" name = "result" class = "w80" value = "<?php echo $assessment['result1'];?>" readonly="readonly"></div>
		<hr>
		<center><?php echo $assessment['percent'];?></center>
	</div>
	<br><br>


</div>

<script type="text/javascript">

$(function() {
	$(".selectbox span").click(function() {
		$(this).parent().find("ul").show();
	});

	$(".selectbox ul li").mouseover(function() {
		$(this).addClass("on");
	});

	$(".selectbox ul li").mouseout(function() {
		$(this).removeClass("on");
	});

	$(".selectbox ul li").click(function() {
		$(this).removeClass("on");
		var id = $(this).attr("val");
		$(this).parent().parent().find("input").val(id);
		$(this).parent().hide();
		$(this).parent().parent().find("span").html($(this).html()+'<img src="http://localhost/kpi/html/./images/arrow_down.png" class = "fr">');
	});
});

</script>
<?php } ?>